import tkinter as tk
from tkinter import ttk
import pyperclip

# 文件名和语言
base_files = [
    "AnyUkit-en-newuser.png",
    "AnyUkit-en-upgrade.png",
    "AnyUkit-en-3device.png",
    "AnyUkit-en-copycode.png",
    "AnyUkit-en-upgrade-education.png",
    "AnyUkit-en-multiuser.png",
    "AnyUkit-en-bundel.png",
    "AnyUkit-en-EDS.png",
    "AnyUkit-en-FreeVSPro.png",
    "AnyUkit-en-leave.png",
    "AnyUkit-en-browse.png"
]

languages = ["it", "de", "fr", "pt", "pl", "es", "ja", "ko", "zh-cn", "zh-tw"]


class RenameGUI:
    def __init__(self, root):
        self.root = root
        self.root.title("文件名复制工具")
        self.root.geometry("700x600")

        # 添加置顶按钮
        self.topmost = tk.BooleanVar(value=False)
        self.pin_button = tk.Checkbutton(
            root,
            text="窗口置顶",
            variable=self.topmost,
            command=self.toggle_topmost
        )
        self.pin_button.pack(anchor="ne", padx=10, pady=5)

        # 使用 Notebook (选项卡)
        notebook = ttk.Notebook(root)
        notebook.pack(fill="both", expand=True, padx=10, pady=10)

        # 每个语言一个 tab
        for lang in languages:
            frame = ttk.Frame(notebook)
            notebook.add(frame, text=lang)

            for base in base_files:
                filename = base.replace("en", lang, 1)
                row_frame = ttk.Frame(frame)
                row_frame.pack(fill="x", pady=2, anchor="w")

                lbl = ttk.Label(row_frame, text=filename)
                lbl.pack(side="left", padx=5)

                btn = ttk.Button(row_frame, text="复制", width=6,
                                 command=lambda text=filename: self.copy_to_clipboard(text))
                btn.pack(side="right", padx=5)

    def copy_to_clipboard(self, text):
        pyperclip.copy(text)
        print(f"已复制: {text}")

    def toggle_topmost(self):
        self.root.attributes("-topmost", self.topmost.get())


if __name__ == "__main__":
    root = tk.Tk()
    app = RenameGUI(root)
    root.mainloop()
